package org.exeed.controller;

import org.exeed.aop.tag.Auth;
import org.exeed.bean.ResultBean;
import org.exeed.entity.ContactEntity;
import org.exeed.entity.SysEntity;
import org.exeed.entity.VideoEntity;
import org.exeed.service.ContactService;
import org.exeed.service.SysService;
import org.exeed.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RequestMapping("/contact")
@RestController
public class ContactController {

    @Autowired
    private ContactService contactService;

    @PostMapping("/save")
    public ResultBean save(@RequestBody ContactEntity contactEntity) {

        contactService.save(contactEntity);

        return ResultBean.succeed();
    }

    @Auth
    @GetMapping("/selectPages")
    public ResultBean selectPages(@RequestParam("page") Integer page, @RequestParam("size") Integer size) {
        return ResultBean.succeed(contactService.selectList(page, size));
    }

    @Auth
    @GetMapping("/getOneById")
    public ResultBean getOneById(@RequestParam("id") Long id) {
        return ResultBean.succeed(contactService.selectById(id));
    }

    @Auth
    @GetMapping("/delete")
    public ResultBean delete(@RequestParam("id") Long id) {
        contactService.delete(id);
        return ResultBean.succeed();
    }
}
